import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;

import com.pi.model.UniformLinearMotionProvider;
import com.pi.vo.VehicleInfo;

/**
 * Just For Test
 */

/**
 * @author Coy.Qiu
 * 
 */
public class RunnerMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		

		
//		UniformLinearMotionProvider provider = new UniformLinearMotionProvider();
//		Map<Calendar, List<VehicleInfo>> map = provider.provideData();
//		
//		for(Map.Entry<Calendar, List<VehicleInfo>> entry : map.entrySet())
//		{
//			System.out.println("The Time stamp is: " + entry.getKey() );
//			List<VehicleInfo> vehicleListForTest = entry.getValue();
//			Iterator<VehicleInfo> iterator = vehicleListForTest.iterator();
//			while (iterator.hasNext()) {
//				VehicleInfo vehicle = iterator.next();
//				System.out.println("Vehicle id = " + vehicle.getVehicleId() + 
//						", type = " + vehicle.getVehicleType() + 
//						", longitude = " + vehicle.getCurrentLocation().getLongitude() + 
//						", latitude = " + vehicle.getCurrentLocation().getLatitude());
//			}
//		}
		
		System.out.println("Hello World");
		for(int i = 0; i < 100; i++) 
		{
			if(i % 5 == 0)
				System.out.println("This number is: " + i);
		}

		
//		SimpleDateFormat dateformatter = new SimpleDateFormat
//		  ("E yyyy.MM.dd 'at' hh:mm:ss a zzz");
//		Calendar currentCalendar = Calendar.getInstance();
//		currentCalendar.add(Calendar.MILLISECOND, + 20000);	//Add 0.2 second to the current time
//		System.out.println("Time is: "
//				  + dateformatter.format(currentCalendar.getTime()));
//		
//		currentCalendar.add(Calendar.MILLISECOND, + 23000);	//Add 0.2 second to the current time
//		System.out.println("2 Time is: "
//				  + dateformatter.format(currentCalendar.getTime()));		
		
//		System.out.println(distance(22.541708,114.086146, 29.46786, -98.53506, "M") + " Miles\n");
//		System.out.println(distance(22.000000,114.009738, 22.009738,114.009738, "K")
//				+ " Kilometers\n");
//		System.out.println(distance(32.9697, -96.80322, 29.46786, -98.53506, "N")
//				+ " Nautical Miles\n");
//
//		Random random = new Random();
//		for (int i = 0; i < 100; i++) {
//			int speed = 0;
//			while (speed < 1 || speed > 120) {
//				speed = (int) (random.nextGaussian() * 10 + 40);
//			}
//			System.out.print(speed + " | ");
//			if (i % 5 == 4) {
//				System.out.println("");
//			}
//		}
	}

	private static double distance(double lat1, double lon1, double lat2, double lon2,
			String unit) {
		double theta = lon1 - lon2;
		double dist = Math.sin(deg2rad(lat1)) * Math.sin(deg2rad(lat2))
				+ Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2))
				* Math.cos(deg2rad(theta));
		dist = Math.acos(dist);
		dist = rad2deg(dist);
		dist = dist * 60 * 1.1515;
		if (unit.equalsIgnoreCase("K")) {
			dist = dist * 1.609344;
		} else if (unit.equalsIgnoreCase("N")) {
			dist = dist * 0.8684;
		}
		return (dist);
	}

	/* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */
	/* :: This function converts decimal degrees to radians : */
	/* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */
	private static double deg2rad(double deg) {
		return (deg * Math.PI / 180.0);
	}

	/* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */
	/* :: This function converts radians to decimal degrees : */
	/* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */
	private static double rad2deg(double rad) {
		return (rad * 180.0 / Math.PI);
	}

}
